import 'package:boss/textStyle/text_style.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

TextStyle _defaultTitleTextStyle = TextStyleConstant().normal_3_28;
TextStyle _defaultValueTextStyle = TextStyleConstant().normal_1_28;

class OrderDetailTitleValue extends StatelessWidget {
  final dynamic value;
  final String title;
  final TextStyle titleTextStyle;
  final TextStyle valueTextStyle;

  const OrderDetailTitleValue({
    Key key,
    this.value,
    this.title,
    this.titleTextStyle,
    this.valueTextStyle,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(
        vertical: 15.w,
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            title,
            style: titleTextStyle ?? _defaultTitleTextStyle,
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: <Widget>[
                if (value is List)
                  for (final item in value)
                    Container(
                      margin: EdgeInsets.only(
                        bottom: 8.w,
                      ),
                      child: Text(
                        item == '' ? '--' : item,
                        style: valueTextStyle ?? _defaultValueTextStyle,
                        overflow: TextOverflow.ellipsis,
                        textAlign: TextAlign.end,
                      ),
                    ),
                if (value is String)
                  Text(
                    value == '' ? '--' : value,
                    style: valueTextStyle ?? _defaultValueTextStyle,
                    overflow: TextOverflow.ellipsis,
                    textAlign: TextAlign.end,
                  ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
